package IO;

import java.io.*;

public class IODemo10 {
    public static void main(String[] args) throws FileNotFoundException {
        //使用字符流 读取文件内容

        try(Reader reader = new FileReader("./test.txt")){
            //读取文件
            while(true){
                char[] buffer = new char[1024];
                //注意：↑这里，跟刚才不同，刚才是byte数组，这里是字符数组
                int n = reader.read(buffer);
                if(n == -1){
                    System.out.println("已经读完了！！！");
                    break;
                }
                String s = new String(buffer,0,n);
                System.out.println("读到的数据是："+s);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
